<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of transaction
 *
 * @author Bui Van Thien
 */
class Model_Transaction extends \Orm\Model
{

    protected static $_properties = array(
        'id',
        'category_id',
        'wallet_id',
        'parent_id',
        'money',
        'created',
        'updated',
        'with_who',
    );
    protected static $_observer = array(
        'Orm/Observer_Created_At' => array(
            'events'          => array('before_insert'),
            'mysql_timestamp' => true,
            'property'        => 'created'
        ),
        'Orm/Observer_Updated_At' => array(
            'events'          => array('before_save'),
            'mysql_timestamp' => true,
            'property'        => 'updated'
        )
    );
    protected static $_table_name = 'tb_transactions';
    protected static $_belong_to = array(
        'category' => array(
            'key_from' => 'id',
            'model_to' => 'Model_Category',
            'key_to'   => 'category_id',
        )
    );
    protected static $_belong_to = array(
        'wallet' => array(
            'key_from' => 'id',
            'model_to' => 'Model_Wallet',
            'key_to'   => 'wallet_id'
        )
    );

}
